package com.bestow.loan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.loan.domain.InvPurchaseRollOut;
import com.bestow.loan.service.IInvPurchaseRollOutService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 申购账户信息Controller
 * 
 * @author liliu
 * @date 2022-09-15
 */
@RestController
@RequestMapping("/loan/purchaseRollOut")
public class InvPurchaseRollOutController extends BaseController
{
    @Autowired
    private IInvPurchaseRollOutService invPurchaseRollOutService;

    /**
     * 查询申购账户信息列表
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvPurchaseRollOut invPurchaseRollOut)
    {
        startPage();
        List<InvPurchaseRollOut> list = invPurchaseRollOutService.selectInvPurchaseRollOutList(invPurchaseRollOut);
        return getDataTable(list);
    }

    /**
     * 导出申购账户信息列表
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:export')")
    @Log(title = "申购账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvPurchaseRollOut invPurchaseRollOut)
    {
        List<InvPurchaseRollOut> list = invPurchaseRollOutService.selectInvPurchaseRollOutList(invPurchaseRollOut);
        ExcelUtil<InvPurchaseRollOut> util = new ExcelUtil<InvPurchaseRollOut>(InvPurchaseRollOut.class);
        util.exportExcel(response, list, "申购账户信息数据");
    }

    /**
     * 获取申购账户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:query')")
    @GetMapping(value = "/{purchaseRollOutId}")
    public AjaxResult getInfo(@PathVariable("purchaseRollOutId") Long purchaseRollOutId)
    {
        return AjaxResult.success(invPurchaseRollOutService.selectInvPurchaseRollOutByPurchaseRollOutId(purchaseRollOutId));
    }

    /**
     * 新增申购账户信息
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:add')")
    @Log(title = "申购账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvPurchaseRollOut invPurchaseRollOut)
    {
        return toAjax(invPurchaseRollOutService.insertInvPurchaseRollOut(invPurchaseRollOut));
    }

    /**
     * 修改申购账户信息
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:edit')")
    @Log(title = "申购账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvPurchaseRollOut invPurchaseRollOut)
    {
        return toAjax(invPurchaseRollOutService.updateInvPurchaseRollOut(invPurchaseRollOut));
    }

    /**
     * 删除申购账户信息
     */
    @PreAuthorize("@ss.hasPermi('loan:purchaseRollOut:remove')")
    @Log(title = "申购账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{purchaseRollOutIds}")
    public AjaxResult remove(@PathVariable Long[] purchaseRollOutIds)
    {
        return toAjax(invPurchaseRollOutService.deleteInvPurchaseRollOutByPurchaseRollOutIds(purchaseRollOutIds));
    }
}
